#include <iostream>
#define N 100

using namespace std;

void asc_sort(char array[], int elements){
int i, j, aux;
for(i=1; i<elements; ++i){
    aux=array[i];
    j=i-1;
    while (aux<array[j] && j>=0){
        array[j+1]=array[j];
        --j;}
		array[j+1]=aux;}
}

int abc_to_ascii(char array[], int elements){
int ascii_array[N];
int i;
for(i=0;i<elements;i++){
ascii_array[i]=(int)array[i];}

for(i=0;i<elements;i++){
cout<<ascii_array[i]<<" ";}

}


void readcharVector(char array[], int elements){
for (int i=0; i<elements; i++){
	cout<<"a["<<i<<"]=";
	cin>>array[i];
	cout<<"\n";}
}

void printcharVector(char array[], int elements){
int i;
for (i=0; i<elements; i++){
    cout<<array[i]<<" ";}
	cout<<"\n";
}

int main(){
char array[N];
int elements;
int i;

cout<<"Type the number of elements you want in the array: ";
cin>>elements;
readcharVector(array,elements);

cout<<"The original array is: ";
for(int i=0; i<elements; i++){
	cout<<array[i]<<" ";}
cout<<endl;

cout<<"The ASCII values for these chars are: "<<endl;
abc_to_ascii(array, elements);
cout<<endl;

asc_sort(array, elements);
cout<<"The ascendent ordered char array is: "<<endl;
printcharVector(array, elements);


return 0;
}
